package com.yidu.drug.service.impl;

import java.sql.Timestamp;
import java.util.Date;
import java.util.List;

import javax.annotation.Resource;

import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;

import com.yidu.drug.action.vo.ContractTableVo;
import com.yidu.drug.dao.ContractTableModelMapper;
import com.yidu.drug.model.ContractTableModel;
import com.yidu.drug.service.ContractTableService;

@Service
public class ContractTableServiceImpl implements ContractTableService{
	@Resource
	private ContractTableModelMapper contractTableModellDao;
	
	/**
	 * 根据id查询数据
	 */
	@Override
	public ContractTableModel findById(String conId) {
		
		return contractTableModellDao.selectByPrimaryKey(conId);
	}
	
	/**
	 * 根据材料ID修改部分信息
	 */
	@Override
	public int updateByPrimaryKeySelective(ContractTableModel ctm) {
		//获取当前时间
		Timestamp ss = new Timestamp(new Date().getTime());
		ctm.setConTime(ss);
		// TODO Auto-generated method stub
		return contractTableModellDao.updateByPrimaryKeySelective(ctm);
	}

	
	/**
	 * 查询所有
	 */
	@Override
	public List<ContractTableModel> findAlls() {
		System.out.println("*-*-*-*-*-*-*-*-*-*-*-*查询成功*-*-*-*-*-*-*-*-*-*-*-*");
		return contractTableModellDao.findAlls();
	}
	
	/**
	 * 增加方法
	 * @return 
	 */
	@Override
	public int add(ContractTableVo vo) {
		ContractTableModel po=new ContractTableModel();
		BeanUtils.copyProperties(vo, po);
		System.out.println("增加成功===============================");
		return contractTableModellDao.insert(po);
	}
	
	/**
	 * 删除的方法
	 */
	@Override
	public void delete(String id) {
		contractTableModellDao.deleteByPrimaryKey(id);
	}

	/**
	 * 王志伟查询合同
	 */
	@Override
	public List<ContractTableModel> findAll() {
		return contractTableModellDao.findAll();
	}

}